<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;
use think\Db;
use think\Validate;
use app\admin\controller\Base;

class Discus extends Base
{
  public function index()
  {
    $pgdata = Db::name('together_discus')->order('id')->paginate(6,true);
    $page = $pgdata->render();
    $data = $pgdata->all();
    foreach($data as $k=>$v){
    	$data[$k]['createtime'] = date('Y-m-d,H:i:s',$v['createtime']);
    }
    // dump($data);die;

    return view('discus/discus',['title'=>'论坛列表','data'=>$data,'page'=>$page]);
  }
  public function del($id)
  {
      // dump($id);die;
  		$data = Db::name('together_discus')->where('id',$id)->delete();
  		$res = Db::name('discus_reply')->where('pid',$id)->delete();
  		 if ($data){
            $this->success('删除成功');
        } else {
            $this->error('删除失败');
        }
  }
}
